home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pas_all.zip / TI118.ASC < prev    next >
Text File  |  1991-09-11  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 118
  10.   VERSION : 2.00x
  11.        OS : PC-DOS, MS-DOS
  12.      DATE : March 13, 1986                               PAGE : 1/2
  13.     TITLE : REDIRECTION OF INPUT/OUTPUT
  14.  
  15.  
  16.  
  17.  
  18.   This program demonstrates user defined INPUT and OUTPUT device
  19.   drivers. Use the indicated portion of the sample program as an
  20.   INCLUDE file to be inserted in declaration section of your
  21.   program files.
  22.  
  23.   The MS-DOS facilities of redirection, piping, and simultaneous
  24.   printing through the use of ^P or ^PrtSc will be re-enabled. At
  25.   the beginning of your main program, place the statements
  26.   (ConInPtr:=Ofs(GetC);) and (ConOutPtr:=Ofs(PutC);). The INPUT and
  27.   OUTPUT from your programs will be redirected through the GetC
  28.   function and the PutC Procedure. Type <Ctrl> <P> at the start of
  29.   your program run and you will get output at both the CRT and the
  30.   printer.}
  31.  
  32.   _________________________________________________________________
  33.  
  34.                        START OF INCLUDE FILE
  35.   _________________________________________________________________
  36.  
  37.   program Redirect:
  38.   Type RegRecord = Record Case Integer Of
  39.                      1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
  40.                      2: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
  41.                    End;
  42.  
  43.   Var    Regs    : RegRecord;
  44.  
  45.   Function GetC: Byte;
  46.  
  47.   Begin
  48.     Regs.AH:=8;
  49.     MsDos(Regs);
  50.     GetC:=Regs.AL;
  51.   End;
  52.  
  53.   Procedure PutC(C: Byte);
  54.  
  55.   Begin
  56.     Regs.AH:=2;
  57.     Regs.DL:=C;
  58.     MsDos(Regs);
  59.   End;
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   PRODUCT : TURBO PASCAL                               NUMBER : 118
  76.   VERSION : 2.00x
  77.        OS : PC-DOS, MS-DOS
  78.      DATE : March 13, 1986                               PAGE : 2/2
  79.     TITLE : REDIRECTION OF INPUT/OUTPUT
  80.  
  81.  
  82.  
  83.  
  84.   ________________________________________________________________
  85.  
  86.                          END OF INCLUDE FILE
  87.   _________________________________________________________________
  88.  
  89.   Var  Str    : String [255];
  90.        I     : integer;
  91.        Answer : char;
  92.  
  93.  
  94.   begin
  95.     ConInPtr:=Ofs(GetC);         { Include these lines at the   }
  96.     ConOutPtr:=Ofs(PutC);       { start of your program     }
  97.     repeat
  98.       ClrScr;
  99.       writeln ('This is a test of INPUT/OUTPUT redirection:  ');
  100.       writeln;
  101.       for I := 1 to 128 do     { demonstrates formated output }
  102.         write (1:5);
  103.       writeln; writeln;
  104.       writeln ('Enter a String of characters from the keyboard.');
  105.       writeln;
  106.       readln (Str);
  107.       writeln;
  108.       writeln (Str);
  109.       writeln; writeln;
  110.       writeln ('Run again? (Y/N)'); writeln;
  111.       writeln ('Type <Ctrl> <P> first to test output to PRINTER/CRT');
  112.       repeat
  113.         read (kbd,Answer);
  114.       until upcase (Answer) in ['Y','N'];
  115.       writeln;
  116.       writeln;
  117.     until upcase (Answer) = 'N';
  118.   end.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.